﻿using System;
using EPiServer;
using EPiServer.Security;
using EPiServer.UI;

namespace OpenWaves.EPiServer
{
    public class AdminPageBase : SystemPageBase
    {
        protected override void OnPreInit(EventArgs e)
        {
            base.OnPreInit(e);

            this.MasterPageFile = EpiServerMasterPageFile;
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            if (PrincipalInfo.HasAdminAccess == false)
            {
                this.AccessDenied();
            }
        }

        public static string EpiServerMasterPageFile
        {
            get
            {
                return UriSupport.ResolveUrlFromUIBySettings("MasterPages/EPiServerUI.master");
            }
        }
    }
}